package main.test.SparkAPI.Baics.collectapi

object testSet {
  def testSets() {
    // The Scala Set class is an iterable collection with no duplicate elements.
    // Scala has mutable and immutable Set class.
    // Adding elements to a Set
    val set = scala.collection.mutable.Set[Int]()

    // with +=, ++=, and add method to add element
    set += 1
    set += 2 += 3
    set ++= Vector(4, 5)
    println("adding 34 is " + set.add(34))

    println(set.mkString("Set( ",", "," )"))

    println("adding 34 now  is " + set.add(34))

    // Deleting elements from a Set
    // with -= and --= methods
    set -= 1
    set -=(2,3)
    // multiple elements defined in another sequence
    set --= Array(4,5)
    println(set.mkString("Set( ",", "," )"))
    // clear and remove
    set.clear()
    println(set.mkString("Set( ",", "," )"))
    val set2 = scala.collection.mutable.Set(1, 2, 3, 4, 5)
    set2.remove(2)
    println(set2.mkString("Set( ",", "," )"))

    println("remove 25 is " + set2.remove(25))

    println(set2.mkString("Set( ",", "," )"))




  }

  def main(args: Array[String]): Unit = {
    testSets()

  }

}
